//
//  XXViewOne.m
//  runTime(动态决议和消息在换发)
//
//  Created by macOS on 2017/4/21.
//  Copyright © 2017年 macOS. All rights reserved.
//

#import "XXViewOne.h"
#import <objc/message.h>


@implementation XXViewOne








- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _p = [Person new];
        _p.delegate = self;
    }
    return self;
}



- (void)run:(Person *)person{
   
    NSLog(@"----%@Person run",NSStringFromClass(self.class));
 
}



- (void)testDelegateFunIsCalledl{
   
    [_p testDelegate];

}


void DynamicMethodIMP(id self, SEL _cmd){

    NSLog(@"--%@这个函数被调用了",NSStringFromSelector(_cmd));
    
}

+ (BOOL)resolveClassMethod:(SEL)sel{
    
    return [super resolveClassMethod:sel];
}

//
//+ (BOOL)resolveInstanceMethod:(SEL)sel{
//    
//    
//    if (sel == @selector(xx)) {
//        class_addMethod(self.class, sel, (IMP)DynamicMethodIMP, "v@:");
//        return YES;
//    }
//
//    return [super resolveInstanceMethod:sel];
//}



- (id)forwardingTargetForSelector:(SEL)aSelector{

  
    id sel = [super forwardingTargetForSelector:aSelector];
    
    return  sel;
    
}



- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector{
  
    NSMethodSignature *signature = [super methodSignatureForSelector:aSelector];
    
    
    return signature;
    
}

- (void)forwardInvocation:(NSInvocation *)anInvocation{



}


@end
